﻿/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

using Daidalos.Utilities;

namespace Daidalos
{

    /// <summary>
    ///     This class implements a 'pimped' version of the regular C# exceptions.
    ///     Features like automated logging are achieved by overriding the 
    ///     exception's constructor.
    /// </summary>
    public class Exception : System.Exception
    {

        #region Constructors
        /// <summary>
        ///     The default constructor is hidden, so that no exceptions
        ///     can be thrown without passing a message to them.
        /// </summary>
        /// <remarks>
        ///     In case a message-less exception is required for some 
        ///     strange reason, feel free to use a standard exception
        ///     located in the 'System' namespace.
        /// </remarks>
        private Exception()
        {
        }

        /// <summary>
        ///     This constructor stores the supplied message, which should
        ///     be used to describe the reason for the exception, using
        ///     the constructor of the base-class.
        /// </summary>
        /// <param name="message">
        ///     A message describing the reason and/or situation under which
        ///     the exception occured.
        /// </param>
        public Exception(string message) : base(message)
        {
            LogManager.Instance.Log("{exception} " + Message);
            // DEBUG: move direct reporting to log manager later (perhaps)!
            System.Windows.Forms.MessageBox.Show(Message, "Exception", 
                System.Windows.Forms.MessageBoxButtons.OK, 
                System.Windows.Forms.MessageBoxIcon.Error);
        }
        #endregion

    }
}